﻿<html>
<head>
<title>Dynamic Test Layout</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js" type="text/javascript"></script>
<script src="http://jquery-ui.googlecode.com/svn/tags/latest/external/jquery.bgiframe-2.1.2.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/i18n/jquery-ui-i18n.min.js" type="text/javascript"></script>
<style type="text/css"> 
	div.flip
	{
		margin:0px;
		padding:5px;
		text-align:left;
		background:#F75D59;
		border:solid 1px #646D7E;
		-moz-border-radius: 15px;
		border-radius: 15px;
	}
	div.panel
	{
		height:120px;
		background:#E77471;
		display:none;
		margin:0px;
		padding:5px;
		border:solid 1px #646D7E;
		-moz-border-radius: 15px;
		border-radius: 15px;
	}
</style>
<script type="text/javascript">
$(document).ready(function(){
	$(".flip").click(function(){
    	$(this).next().slideToggle("normal");
  });
});
</script>
</head>
<?php include "layout.php";?>
	<div id="content">
		<?php
		$db = mysql_connect("mysql513.in.shared-server.net:16033", "JRtu434", "qvoiceDB1");
 		mysql_select_db("JRtu434", $db);
 		mysql_query("set SQL_BIG_Selects=1");
		$status = array("all"=>"All","live"=>"Live","closed"=>"Closed","temp"=>"Temp Closed","po"=>"Waiting for PO","ids"=>"Waiting for IDs","inv"=>"Waiting for Invoice","pay"=>"Waiting for Payment","test"=>"TEST","repo"=>"Report");
 		$result = mysql_query("Select projects.ID as ID,name as name,state as status,
	  	sum(if(status=\"complete\",1,0)) as complete,cpc,
	  	cpc*ss as mmkingaku,
  		cpc*sum(if(status=\"complete\",1,0)) as total,
	  	sum(if(status=\"screenout\",1,0)) as screenout,
	  	sum(if(status=\"quotafull\",1,0)) as quotafull, 
	  	sum(if(status=\"short\",1,0)) as short,
	  	sum(if(status=\"gate\",1,0)) as gate,
	  	sum(if(status is null,1,0)) as empty, 
	  	sum(if(status=\"complete\",1,0))/(sum(if(status=\"complete\",1,0))+sum(if(status=\"screenout\",1,0)))*100 as IR
	  	from testredirect,projects
	  	where state=\"live\" and testredirect.rid=projects.rid group by name order by complete desc");
		//Put the projects into their individual divs
		setlocale(LC_MONETARY, 'en_US');
		$contractTotal =0;
		$runningTotal =0;
		$averageIR = 0;
		$count =0;
		while($row = mysql_fetch_array($result))
	 	 {
	  		?>
	  		<div class="flip">
	  			<?=$row['name']?> Status: <?=$row['status']?> Completes: <?=$row['complete']?>
	  		</div>
	  		<div class="panel">
	  			<button type="button" name="download" value="<?=$row['name']?>">IDs</button>
				見積金額： <?=$row['mmkingaku']?>
				CPC : <?=$row['cpc']?>
				<br>
	  			<button type="button" name="view" value="<?=$row['ID']?>">View</button>
				Current Total: <?=$row['total']?> 
				Completes: <?=$row['complete']?>
				<br>
	  			<button type="button" name="view" value="<?=$row['ID']?>">Edit</button>
				<br>
	  			<?=$row["complete"]?>
	  		</div>
	  	<?php
	  	mysql_close;
	  	}
 		?>
    	
  	</div>
	<div id="taskbox">
	<p>This is a test</p>
	</div>
</body>

</html> 
